import request from '@/utils/request'

// 查询违规处理列表
export function listViolation(query) {
  return request({
    url: '/violation/list',
    method: 'get',
    params: query
  })
}

// 查询违规处理详细
export function getViolation(id) {
  return request({
    url: '/violation/' + id,
    method: 'get'
  })
}

// 新增违规处理
export function addViolation(data) {
  return request({
    url: '/violation',
    method: 'post',
    data: data
  })
}

// 修改违规处理
export function updateViolation(data) {
  return request({
    url: '/violation',
    method: 'put',
    data: data
  })
}

// @/api/system/violation.js
export function updateViolationStatus(id,userId,appealStatus) { // ✅ 正确：接收一个对象参数
  return request({
    url: '/violation/updateStatus',
    method: 'put',
    data: {
      "id": id,
      "userId": userId,
      "appealStatus": appealStatus
    
    }
  })
}

export function rejectViolation(id,userId) {
  return request({
    method: 'put',
    url: '/violation/reject',
    data: {
      "id": id,
      "userId": userId
    }})
}
// 删除违规处理
export function delViolation(id) {
  return request({
    url: '/violation/' + id,
    method: 'delete'
  })
  
}

export function importUncheckedToViolation(){
  return request({
    url: '/violation/importUncheckedToViolation',
    method: 'get',
  })
}


export async function getUserNameById(id){
  const res=await request({
    url: '/user/getUserNameById',
  })
}